﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="ListMapUser.aspx.cs" Inherits="jnlamp.Web.mapinfo.ListMapUser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
     <%--<script src="../Script/sitedata.js"></script>
    <script src="../Script/city.js"></script>
    <script src="../Script/combobox.js"></script>
    <script src="../Script/prositedata.js"></script>
    <script src="../Script/username.js"></script>    --%>
    <style>
        html, body {
            height:100%
        } 
    </style>
    <script type="text/javascript">  
        var sprovince = "";
        var scity = "";
        var scounty = "";
        $.extend($.fn.tree.methods, {
            getLevel: function (jq, target) {
                var l = $(target).parentsUntil("ul.tree", "ul");
                return l.length + 1;
            }
        });
        $(function () {
            InitTree();
            InitGird();
            InitSearch();            
        });
        function InitTree() {
            $('#pt').tree({
                width: '100%', //宽度                
                lines: true,
                //data: provincetree,   
                url: '../areainfo/GetArea.ashx', //请求数据的页面 
                method: 'post',
                queryParams: { "action": "querymyarea" },
                onBeforeExpand: function (node) {
                    $("#pt").tree("options").queryParams = { "action": "queryyb" };
                    $('#pt').tree('options').url = "../areainfo/GetArea.ashx?pid=" + node.id;
                },
                onClick: function (node) {
                    if (node.text != "") {
                        var lv = $('#pt').tree("getLevel", node.target);
                        var bm = node.bm;                        
                        if (lv == 1) {
                            sprovince=node.text;
                        }
                        if (lv == 2) {
                            scity = node.text;
                            sprovince=$('#pt').tree("getParent", node.target).text;
                        }
                        if (lv == 3) {
                            scounty =node.text;
                            var node1 = $('#pt').tree("getParent", node.target)
                            scity = node1.text;
                            sprovince=$('#pt').tree("getParent", node1.target).text;
                        }
                        reloadgrid()
                    }
                },
                onLoadSuccess: function (node, param) {
                    //$('#pt').tree("collapseAll");
                }
            });
        }
        function getQueryParams(queryParams) {
            //var sprovince = $("#spro").val();
            //var scity = $("#scity").val();
            //var scounty = $("#scou").val();
            queryParams.spro = sprovince;
            queryParams.scity = scity;
            queryParams.scou = scounty;
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {

            //查询参数直接添加在queryParams中      
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');

        }

        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '用户列表', //表格标题
                url: '../userinfo/GetUser.ashx', //请求数据的页面
                sortName: 'uname', //排序字段
                idField: 'uid', //标识字段,主键
                iconCls: '', //标题左边的图标
                //width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: true,
                method: 'post',
                columns: [[
                    
	                { title: '用户名', field: 'uname', width: 60, sortable: true },
                    { title: '单位名称', field: 'uunit', width: 120 },
                    { title: '单位电话', field: 'utel', width: 60 },
                    { title: '单位邮箱', field: 'uemail', width: 120 },
                    { title: '负责人', field: 'utruename', width:50 },
                    { title: '手机', field: 'uphone', width: 60 },
                    { title: '单位地址', field: 'madd', width: 160 },
                    {
                        title: '用户等级', field: 'ulevel', width: 60, formatter: function (value, row, index) {
                            if (value == 0) {
                                return "普通用户";
                            } else if (value == 1) {
                                return "县级用户";
                            } else if (value == 2) {
                                return "市级用户";
                            } else if (value == 3) {
                                return "省级用户";
                            } else if (value == 4) {
                                return "全国用户";
                            } else if (value == 5) {
                                return "管理员";
                            } else if (value == -1) {
                                return "省级代理商";
                            }
                        }
                    },
                    {
                        title: '设置测报点', field: 'm', width: 50, formatter: function (value, row, index) {
                            return '<a href="#" onclick="top.addTab(\'设置测报站' + row.uname + '\',\'/mapinfo/list.aspx?uid=' + row.uid + '&pro=' +encodeURI(encodeURI(row.uprovince))  + '&city=' + encodeURI(encodeURI(row.ucity)) + '&county=' + encodeURI(encodeURI(row.ucounty)) + '\', \'icon icon-magic\');">设置</a>';
                        }

                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "querya" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });


        }
       
        function InitSearch() {
            $("#ipt_search").searchbox({
                width: 200,
                //iconCls: 'icon-save',
                searcher: function (val, name) {
                    $('#tt').datagrid('options').queryParams.search_type = name;
                    $('#tt').datagrid('options').queryParams.search_value = val;
                    $('#tt').datagrid('reload');
                },
                prompt: '请输入查询信息'
            });
        }       
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <div class="easyui-layout" style="width:100%; height:100%;" id="mycon">
        <div region="west" split="true" title="区域检索" style="width: 180px;overflow:scroll" id="west">
            <ul id="pt"></ul>
        </div>
        <div region="center" style="background: #eee; overflow-y: hidden">
            <table id="tt">
            </table>
        </div>


        <div id="tab_toolbar" style="padding: 4px;">
            <table cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td style="text-align: right; padding-right: 15px">
                        <input id="ipt_search" menu="#search_menu" />
                        <div id="search_menu" style="width: 120px">
                            <div name="usernum">
                                用户名
                            </div>
                            <div name="username">
                                姓 名
                            </div>
                        </div>
                    </td>
                </tr>
            </table>

        </div>       
    </div>
</asp:Content>
